package visiopuce.graph;

import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.plot.IntervalMarker;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.ui.TextAnchor;

import visiopuce.objets.Alteration;

public class RegionGraphique {

	private List<String> titreLignes;

	public List<String> getTitreLignes() {
		return titreLignes;
	}

	public void setTitreLignes(List<String> titreLignes) {
		this.titreLignes = titreLignes;
	}

	// private CombinedDomainXYPlot combineddomainxyplot;

	private XYFloatingBarDataset xyFloatingBarDataset;

	private DefaultXYDataset xySeriesCollection;

	private XYPlot chromosomePlot;

	// private XYPlot statPlot;

	private OutilsBande2 ob;

	private ArrayList<Integer> idPuceANePasMettre;

	private String chromosome;

	private long debutAlt;

	private long finAlt;

	private int idPuce;

	private XYPlot overviewChromosomePlot;

	private long debut;

	private long fin;

	private JFreeChart jfreechart;

	private GraphCytog graph;

	private Map<String, Boolean> selected;

	// public RegionGraphique(GraphCytog graph, Map<String, Boolean> selected,
	// String chromosome, int debut, int fin, int debutAlt, int finAlt, int
	// idPuce, int pas) {
	// this.graph = graph;
	// this.chromosome = chromosome;
	// this.debutAlt = debutAlt;
	// this.finAlt = finAlt;
	// this.idPuce = idPuce;
	// this.debut = debut;
	// this.fin = fin;
	// this.selected = selected;
	// ob = new OutilsBande2(graph, chromosome, debut, fin, pas);
	// idPuceANePasMettre = new ArrayList<Integer>();
	// }

	public RegionGraphique(GraphCytog graphCytog, Map<String, Boolean> selected2, Alteration alteration, long debut2, long fin2, int seuil) {
		this.graph = graphCytog;
		this.chromosome = alteration.getChromosome();
		this.debutAlt = alteration.getDebutHg19();
		this.finAlt = alteration.getFinHg19();
		if (alteration.getIdAlteration() > 0) {
			this.idPuce = alteration.getPuce().getIdPuce();
		} else {
			this.idPuce = 0;
		}
		this.debut = debut2;
		this.fin = fin2;
		this.selected = selected2;
		ob = new OutilsBande2(graph, chromosome, debut, fin, seuil);
		idPuceANePasMettre = new ArrayList<Integer>();
	}

	public GraphCytog getGraph() {
		return graph;
	}

	public void setGraph(GraphCytog graph) {
		this.graph = graph;
	}

	public JFreeChart creationGraphs() {
		jfreechart = null;
		try {
			// combineddomainxyplot = new CombinedDomainXYPlot(new
			// NumberAxis2("Carte physique du chromosome " + chromosome, debut,
			// fin));
			// this.statPlot = createGraphStat();
			// combineddomainxyplot.add(statPlot, 30);
			this.chromosomePlot = createGraphChomosome();
			// combineddomainxyplot.add(chromosomePlot, 70);
			// ((XYPlot)
			// combineddomainxyplot.getSubplots().get(1)).getRangeAxis().setAutoRange(false);

			IntervalMarker intervalleP = new IntervalMarker(debutAlt, debutAlt + 1);
			intervalleP.setPaint(Color.BLACK);
			IntervalMarker intervalleM = new IntervalMarker(finAlt, finAlt + 1);
			intervalleM.setPaint(Color.BLACK);

			// statPlot.addDomainMarker(intervalleP);
			// statPlot.addDomainMarker(intervalleM);
			// statPlot.getRangeAxis().setLabelFont(new Font("SansSerif",
			// Font.PLAIN, 12));
			// statPlot.getRangeAxis().setTickLabelFont(new Font("SansSerif",
			// Font.PLAIN, 12));

			chromosomePlot.addDomainMarker(intervalleP);
			chromosomePlot.addDomainMarker(intervalleM);
			chromosomePlot.getRangeAxis().setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
			chromosomePlot.getRangeAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));

			chromosomePlot.getDomainAxis().setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
			chromosomePlot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
			chromosomePlot.getDomainAxis().addChangeListener(new AxisGraphChangeListener(this));

			// combineddomainxyplot.getDomainAxis().setLabelFont(new
			// Font("SansSerif", Font.PLAIN, 12));
			// combineddomainxyplot.getDomainAxis().setTickLabelFont(new
			// Font("SansSerif", Font.PLAIN, 12));
			// combineddomainxyplot.getDomainAxis().addChangeListener(new
			// AxisGraphChangeListener(this));

			jfreechart = new JFreeChart("Chromosome " + chromosome, chromosomePlot);
			jfreechart.setBackgroundPaint(Color.white);
			jfreechart.setAntiAlias(true);
			jfreechart.getLegend().visible = false;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jfreechart;
	}

	// public JFreeChart creationOverviewGraph() {
	// FloatingBarSeriesCollection floatingBarseriescollection = new
	// FloatingBarSeriesCollection();
	// floatingBarseriescollection.add(ob.getBandesChrBandes());
	// XYFloatingBarDataset floatingBarDataset = new
	// XYFloatingBarDataset(floatingBarseriescollection);
	// floatingBarDataset.setTransposed(true);
	// floatingBarDataset.setSeriesWidth(0.59999999999999998D);
	//
	// NumberAxis2 carteAxis = new NumberAxis2();
	// // carteAxis.setAutoRange(false);
	//
	// String[] sa = { "Chr " + chromosome };
	//
	// SymbolAxis2 symbolaxis = new SymbolAxis2("", sa);
	// symbolaxis.setGridBandsVisible(false);
	//
	// // Optimise l'Axe Y
	// symbolaxis.setStandardTickUnits(NumberAxis2.createIntegerTickUnits());
	// symbolaxis.setAutoRange(false);
	// symbolaxis.setRange(-1, 1);
	// symbolaxis.setTickMarksVisible(false);
	// symbolaxis.setInverted(true);
	// symbolaxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
	//
	// BarToolTipGenerator barToolTipGenerator = new BarToolTipGenerator();
	// FloatingBarItemRenderer rend = new
	// FloatingBarItemRenderer(floatingBarDataset, barToolTipGenerator);
	// rend.setUseYInterval(true);
	// rend.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 7));
	// rend.setItemLabelGenerator(barToolTipGenerator);
	// rend.setItemLabelsVisible(true);
	// rend.setPositiveItemLabelPosition(new
	// ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
	// TextAnchor.CENTER, -Math.PI / 2));
	// rend.setBaseToolTipGenerator(barToolTipGenerator);
	//
	// overviewChromosomePlot = new XYPlot(floatingBarDataset, carteAxis,
	// symbolaxis, rend);
	//
	// double lower = combineddomainxyplot.getDomainAxis().getLowerBound();
	// double upper = combineddomainxyplot.getDomainAxis().getUpperBound();
	// IntervalMarker intervalleP = new IntervalMarker(lower, upper);
	// intervalleP.setPaint(Color.YELLOW);
	//
	// overviewChromosomePlot.removeDomainMarker(intervalleP);
	// overviewChromosomePlot.addDomainMarker(intervalleP);
	//
	// JFreeChart jfreechart = new JFreeChart("Chromosome " + chromosome,
	// overviewChromosomePlot);
	//
	// return jfreechart;
	// }

	// private XYPlot createGraphStat() {
	// XYLineAndShapeRenderer xylineandshaperenderer = new
	// XYLineAndShapeRenderer();
	// xylineandshaperenderer.setAutoPopulateSeriesShape(false);
	//
	// // Atteints (del 0)
	// xylineandshaperenderer.setSeriesPaint(0, GraphCytog.COLOR_CNV_0);
	// xylineandshaperenderer.setSeriesShapesVisible(0, true);
	// // Atteints (del 1)
	// xylineandshaperenderer.setSeriesPaint(1, GraphCytog.COLOR_CNV_1);
	// xylineandshaperenderer.setSeriesShapesVisible(1, true);
	// // Atteints (dup 3)
	// xylineandshaperenderer.setSeriesPaint(2, GraphCytog.COLOR_CNV_3);
	// xylineandshaperenderer.setSeriesShapesVisible(2, true);
	// // Atteints (dup 4)
	// xylineandshaperenderer.setSeriesPaint(3, GraphCytog.COLOR_CNV_4);
	// xylineandshaperenderer.setSeriesShapesVisible(3, true);
	//
	// // Non atteints (del 0)
	// xylineandshaperenderer.setSeriesPaint(4, GraphCytog.COLOR_CNV_0);
	// xylineandshaperenderer.setSeriesShapesVisible(4, false);
	// // Non atteints (del 1)
	// xylineandshaperenderer.setSeriesPaint(5, GraphCytog.COLOR_CNV_1);
	// xylineandshaperenderer.setSeriesShapesVisible(5, false);
	// // Non atteints (dup 3)
	// xylineandshaperenderer.setSeriesPaint(6, GraphCytog.COLOR_CNV_3);
	// xylineandshaperenderer.setSeriesShapesVisible(6, false);
	// // Non atteints (dup 4)
	// xylineandshaperenderer.setSeriesPaint(7, GraphCytog.COLOR_CNV_4);
	// xylineandshaperenderer.setSeriesShapesVisible(7, false);
	//
	// // Non atteints (moz)
	// xylineandshaperenderer.setSeriesPaint(8, GraphCytog.COLOR_CNV_MOZ);
	// xylineandshaperenderer.setSeriesShapesVisible(8, false);
	// // Atteints (moz)
	// xylineandshaperenderer.setSeriesPaint(9, GraphCytog.COLOR_CNV_MOZ);
	// xylineandshaperenderer.setSeriesShapesVisible(9, true);
	// // Non atteints (LCSH)
	// xylineandshaperenderer.setSeriesPaint(10, GraphCytog.COLOR_CNV_LCSH);
	// xylineandshaperenderer.setSeriesShapesVisible(10, false);
	// // Atteints (LCSH)
	// xylineandshaperenderer.setSeriesPaint(11, GraphCytog.COLOR_CNV_LCSH);
	// xylineandshaperenderer.setSeriesShapesVisible(11, true);
	//
	// float dash[] = { 20.0f, 50.0f };
	// // xylineandshaperenderer.setSeriesStroke(0,
	// // new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
	// // BasicStroke.JOIN_MITER, 1.0f, dash, 0.0f));
	// // xylineandshaperenderer.setSeriesStroke(1,
	// // new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
	// // BasicStroke.JOIN_MITER, 1.0f, dash, 0.0f));
	// // xylineandshaperenderer.setSeriesStroke(2,
	// // new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
	// // BasicStroke.JOIN_MITER, 1.0f, dash, 0.0f));
	// // xylineandshaperenderer.setSeriesStroke(3,
	// // new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
	// // BasicStroke.JOIN_MITER, 1.0f, dash, 0.0f));
	// Ellipse2D.Double p1 = new Ellipse2D.Double(-1.5, -1.5, 3, 3);
	//
	// xylineandshaperenderer.setSeriesShape(0, p1);
	// xylineandshaperenderer.setSeriesShape(1, p1);
	// xylineandshaperenderer.setSeriesShape(2, p1);
	// xylineandshaperenderer.setSeriesShape(3, p1);
	// xylineandshaperenderer.setSeriesShape(9, p1);
	// xylineandshaperenderer.setSeriesShape(11, p1);
	// xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(9, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(11, new BasicStroke(1.0f));
	//
	// xylineandshaperenderer.setSeriesStroke(4, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(5, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(6, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(7, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(8, new BasicStroke(1.0f));
	// xylineandshaperenderer.setSeriesStroke(10, new BasicStroke(1.0f));
	//
	// NumberAxis2 numberaxis = new NumberAxis2("Nb CNV de la base", debut,
	// fin);
	// numberaxis.setAutoRange(true);
	// numberaxis.setLowerMargin(0.10000000000000001D);
	// numberaxis.setUpperMargin(0.10000000000000001D);
	// xySeriesCollection = creationDonneesStat();
	// statPlot = new XYPlot(xySeriesCollection, new
	// NumberAxis2("Carte physique du chromosome", debut, fin), numberaxis,
	// xylineandshaperenderer);
	//
	// return statPlot;
	// }

	// private DefaultXYDataset creationDonneesStat() {
	// DefaultXYDataset xySeriesCol = new DefaultXYDataset();
	// List<double[][]> l = ob.calculeCNVPosition();
	// xySeriesCol.addSeries("Atteints (del 0)", l.get(0));
	// xySeriesCol.addSeries("Atteints (del 1)", l.get(1));
	// xySeriesCol.addSeries("Atteints (dup 3)", l.get(2));
	// xySeriesCol.addSeries("Atteints (dup 4)", l.get(3));
	//
	// xySeriesCol.addSeries("Non atteints (del 0)", l.get(4));
	// xySeriesCol.addSeries("Non atteints (del 1)", l.get(5));
	// xySeriesCol.addSeries("Non atteints (dup 3)", l.get(6));
	// xySeriesCol.addSeries("Non atteints (dup 4)", l.get(7));
	//
	// xySeriesCol.addSeries("Non atteints (moz)", l.get(8));
	// xySeriesCol.addSeries("Atteints (moz)", l.get(9));
	// xySeriesCol.addSeries("Non atteints (LCSH)", l.get(10));
	// xySeriesCol.addSeries("Atteints (LCSH)", l.get(11));
	// return xySeriesCol;
	// }

	public XYPlot createGraphChomosome() {
//		Runnable longJob = new Runnable() {
//			boolean done = false;
//
//			public void run() {
//				Thread thread = new Thread(new Runnable() {
//					public void run() {
//						xyFloatingBarDataset = creationDonneesChromosome();
//						done = true;
//					}
//				});
//				thread.start();
//				while (!done) {
//					if (!Display.getCurrent().readAndDispatch())
//						Display.getCurrent().sleep();
//				}
//			}
//		};
		xyFloatingBarDataset = creationDonneesChromosome();
//		BusyIndicator.showWhile(graph.getcGraph().getDisplay(), longJob);
		NumberAxis2 carteAxis = new NumberAxis2("Carte physique du chromosome", debut, fin);
		carteAxis.setAutoRange(false);

		SymbolAxis2 symbolaxis = new SymbolAxis2("Type de séquence", titreLignes.toArray(new String[titreLignes.size()]));
		symbolaxis.setGridBandsVisible(true);

		// Optimise l'Axe Y
		symbolaxis.setStandardTickUnits(NumberAxis2.createIntegerTickUnits());
		symbolaxis.setAutoRange(false);
		symbolaxis.setRange(-1, 14);
		symbolaxis.setTickMarksVisible(true);
		symbolaxis.setInverted(true);
		symbolaxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));

		BarToolTipGenerator barToolTipGenerator = new BarToolTipGenerator();
		FloatingBarItemRenderer rend = new FloatingBarItemRenderer(xyFloatingBarDataset, barToolTipGenerator);
		rend.setUseYInterval(true);
		rend.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 12));
		rend.setItemLabelGenerator(barToolTipGenerator);
		rend.setItemLabelsVisible(true);
		rend.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
		rend.setBaseToolTipGenerator(barToolTipGenerator);

		// ,
		// TextAnchor.TOP_LEFT, (31 * Math.PI / 16)));
		rend.setToolTipGenerator(barToolTipGenerator);

		chromosomePlot = new XYPlot(xyFloatingBarDataset, carteAxis, symbolaxis, rend);
		chromosomePlot.setNoDataMessage("Aucune donnée!");
		chromosomePlot.setBackgroundPaint(new Color(230, 250, 254));
		chromosomePlot.setOutlinePaint(Color.BLACK);
		chromosomePlot.setRangeGridlinePaint(Color.gray);
		chromosomePlot.setRangeGridlinesVisible(false);
		return chromosomePlot;
	}

	public XYFloatingBarDataset creationDonneesChromosome() {

		titreLignes = new ArrayList<String>();
		FloatingBarSeriesCollection floatingBarseriescollection = new FloatingBarSeriesCollection();

		if (selected.containsKey("Séquences génomiques issues de NCBI") && selected.get("Séquences génomiques issues de NCBI").booleanValue()) {
			List<FloatingBar> genes = ob.getGeneNCBIBandes();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Seq NCBI (1/4)");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Seq NCBI (2/4)");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Seq NCBI (3/4)");
			FloatingBarSeries floatingBarseries7 = new FloatingBarSeries("Seq NCBI (4/4)");
			FloatingBarSeries floatingBarseries9 = new FloatingBarSeries("Région PAR1&2");
			int i = 0;
			FloatingBar floatingBarOld = null;
			for (FloatingBar floatingBar : genes) {
				if (floatingBar.getToolTip().equals("région pseudo-autosomique")) {
					floatingBarseries9.add(floatingBar);
				} else {
					if (i % 4 == 0) {
						floatingBarseries4.add(floatingBar);
					} else if (i % 4 == 1) {
						floatingBarseries5.add(floatingBar);
					} else if (i % 4 == 2) {
						floatingBarseries6.add(floatingBar);
					} else {
						floatingBarseries7.add(floatingBar);
					}

					i++;
				}
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			floatingBarseriescollection.add(floatingBarseries7);
			floatingBarseriescollection.add(floatingBarseries9);
			titreLignes.add("Seq NCBI (1/4)");
			titreLignes.add("Seq NCBI (2/4)");
			titreLignes.add("Seq NCBI (3/4)");
			titreLignes.add("Seq NCBI (4/4)");
			titreLignes.add("Région PAR1&2)");
		}
		if (selected.containsKey("Syndromes liés à des microremaniements issus de Decipher") && selected.get("Syndromes liés à des microremaniements issus de Decipher").booleanValue()) {
			floatingBarseriescollection.add(ob.getBaseMicroRem().get(0));
			floatingBarseriescollection.add(ob.getBaseMicroRem().get(1));
			floatingBarseriescollection.add(ob.getBaseMicroRem().get(2));
			titreLignes.add("Micro Del.");
			titreLignes.add("Micro Dup.");
			titreLignes.add("Micro Rem.");
		}
		if (selected.containsKey("Bandes chomosomiques") && selected.get("Bandes chomosomiques").booleanValue()) {
			floatingBarseriescollection.add(ob.getBandesChrBandes());
			titreLignes.add("Bandes");
		}

		// if (confPanel.cbSNP6 != null && confPanel.cbSNP6.isSelected()) {
		// floatingBarseriescollection.add(ob.getCNSNP6Bandes());
		// titreLignes.add("Affy SNP 6.0");
		// }
		if (selected.containsKey("Marqueurs de la puce") && selected.get("Marqueurs de la puce").booleanValue()) {
			floatingBarseriescollection.add(ob.getProbeBandes());
			titreLignes.add("Mq. de la puce");
		}

		// if (confPanel.cbFlanquant != null &&
		// confPanel.cbFlanquant.isSelected()) {
		// List<FloatingBar> patients = ob.getCNVsBaseByIdPuce(idPuce);
		//
		// if (patients != null) {
		//
		// FloatingBarSeries floatingBarseries9 = new FloatingBarSeries(
		// "Marqueurs flanquants");
		// List<FloatingBar> snp6s = ob.getSNP6FlanquantBandes();
		// snp6s.addAll(ob.getSNP6FlanquantBandes());
		// for (FloatingBar floatingBar : snp6s) {
		// floatingBarseries9.add(floatingBar);
		// }
		// List<FloatingBar> cn6s = ob.getCNSNP6FlanquantBandes();
		// cn6s.addAll(ob.getCNSNP6FlanquantBandes());
		// for (FloatingBar floatingBar : cn6s) {
		// floatingBarseries9.add(floatingBar);
		// }
		// floatingBarseriescollection.add(floatingBarseries9);
		// titreLignes.add("Marqueurs flanquants");
		//
		// }
		//
		// }

		// if (confPanel.cbFlanquant != null &&
		// confPanel.cbFlanquant.isSelected()) {
		// List<FloatingBar> patients = ob.getCNVsBaseByIdPuce(idPuce);
		//
		// if (patients != null) {
		//
		// FloatingBarSeries floatingBarseries9 = new FloatingBarSeries(
		// "Marqueurs flanquants");
		// List<FloatingBar> probes = ob.getProbeFlanquantBandes();
		// probes.addAll(ob.getProbeFlanquantBandes());
		// for (FloatingBar floatingBar : probes) {
		// floatingBarseries9.add(floatingBar);
		// }
		// floatingBarseriescollection.add(floatingBarseries9);
		// titreLignes.add("Mq. flanquants");
		//
		// }
		//
		// }
		
		if (idPuce > 0 && selected.containsKey("CNV du patient") && selected.get("CNV du patient").booleanValue()) {
			FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("CNV dossier");
			List<FloatingBar> patients = ob.getCNVsBaseByIdPuce(idPuce);

			if (patients != null) {

				for (FloatingBar floatingBar : patients) {
					floatingBarseries8.add(floatingBar);
				}
				floatingBarseriescollection.add(floatingBarseries8);
				titreLignes.add("CNV dossier");
				idPuceANePasMettre.add(idPuce);

			}

		}
		if (idPuce > 0 && selected.containsKey("CNV du patient (autre puce)") && selected.get("CNV du patient (autre puce)").booleanValue()) {
			HashMap<Integer, String> idPuceParents = new HashMap<Integer, String>();
			idPuceParents = ob.getAutrePucePatient(true);
			Set<Integer> keys = idPuceParents.keySet();
			for (Integer idAutrePucePatient : keys) {
				String titre = idPuceParents.get(idAutrePucePatient);
				List<FloatingBar> autresPuces = ob.getCNVsBaseByIdPuce(idAutrePucePatient);
				FloatingBarSeries floatingBarseries8 = new FloatingBarSeries(titre);
				if (autresPuces != null) {
					for (FloatingBar floatingBar : autresPuces) {
						floatingBarseries8.add(floatingBar);
					}
					floatingBarseriescollection.add(floatingBarseries8);
					titreLignes.add(titre);
					idPuceANePasMettre.add(idAutrePucePatient);
				}

			}

		}
		if (idPuce > 0 && selected.containsKey("CNV de la famille") && selected.get("CNV de la famille").booleanValue()) {
			HashMap<Integer, String> idPuceFamilles = new HashMap<Integer, String>();
			idPuceFamilles = ob.getPuceFamille(false);
			Set<Integer> keys = idPuceFamilles.keySet();
			for (Integer idPuceFamille : keys) {
				String titre = idPuceFamilles.get(idPuceFamille);
				List<FloatingBar> parents = ob.getCNVsBaseByIdPuce(idPuceFamille);
				FloatingBarSeries floatingBarseries8 = new FloatingBarSeries(titre);
				if (parents != null) {
					for (FloatingBar floatingBar : parents) {
						floatingBarseries8.add(floatingBar);
					}
					floatingBarseriescollection.add(floatingBarseries8);
					titreLignes.add(titre);
					idPuceANePasMettre.add(idPuceFamille);
				}

			}
		}
		if (selected.containsKey("CNV chevauchants") && selected.get("CNV chevauchants").booleanValue()) {
			HashMap<Integer, List<FloatingBar>> cnvChevanchants = ob.getCNVChevauchantCNV();
			HashMap<Integer, Integer> ordreCNV = ob.getOrdreCNVChevauchantCNV();
			for (int i = 0; i < ordreCNV.size(); i++) {
				if (!idPuceANePasMettre.contains(ordreCNV.get(i))) {
					if (cnvChevanchants.containsKey(ordreCNV.get(i))) {
						List<FloatingBar> listeFloatingBar = cnvChevanchants.get(ordreCNV.get(i));
						FloatingBar fBar = listeFloatingBar.get(0);
						String[] titreLigne = fBar.getDescription().split("-");
						FloatingBarSeries floatingBarseries8 = new FloatingBarSeries(titreLigne[0] + "-" + titreLigne[1]);
						for (FloatingBar floatingBar : listeFloatingBar) {
							floatingBarseries8.add(floatingBar);
						}
						floatingBarseriescollection.add(floatingBarseries8);
						titreLignes.add(titreLigne[0] + "-" + titreLigne[1]);
					}
				}
			}
		}
		if (selected.containsKey("CNV en délétion") && selected.get("CNV en délétion").booleanValue()) {

			HashMap<Integer, List<FloatingBar>> cnvChevanchants = ob.getCNVChevauchantDelCNV();
			HashMap<Integer, Integer> ordreCNV = ob.getOrdreCNVChevauchantDelCNV();
			for (int i = 0; i < ordreCNV.size(); i++) {
				if (!idPuceANePasMettre.contains(ordreCNV.get(i))) {
					if (cnvChevanchants.containsKey(ordreCNV.get(i))) {
						List<FloatingBar> listeFloatingBar = cnvChevanchants.get(ordreCNV.get(i));
						FloatingBar fBar = listeFloatingBar.get(0);
						FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("" + fBar.getDescription());
						for (FloatingBar floatingBar : listeFloatingBar) {
							floatingBarseries8.add(floatingBar);
						}
						floatingBarseriescollection.add(floatingBarseries8);
						titreLignes.add(fBar.getDescription());
					}
				}
			}
		}
		if (selected.containsKey("CNV en duplication") && selected.get("CNV en duplication").booleanValue()) {

			HashMap<Integer, List<FloatingBar>> cnvChevanchants = ob.getCNVChevauchantDupCNV();
			HashMap<Integer, Integer> ordreCNV = ob.getOrdreCNVChevauchantDupCNV();
			for (int i = 0; i < ordreCNV.size(); i++) {
				if (!idPuceANePasMettre.contains(ordreCNV.get(i))) {
					if (cnvChevanchants.containsKey(ordreCNV.get(i))) {
						List<FloatingBar> listeFloatingBar = cnvChevanchants.get(ordreCNV.get(i));
						FloatingBar fBar = listeFloatingBar.get(0);
						FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("" + fBar.getDescription());
						for (FloatingBar floatingBar : listeFloatingBar) {
							floatingBarseries8.add(floatingBar);
						}
						floatingBarseriescollection.add(floatingBarseries8);
						titreLignes.add(fBar.getDescription());
					}
				}
			}
		}
		if (selected.containsKey("Clones 32K") && selected.get("Clones 32K").booleanValue()) {

			List<FloatingBar> clone = ob.getClone32kBandes();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries7 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries9 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries10 = new FloatingBarSeries("Clones 32K");
			FloatingBarSeries floatingBarseries11 = new FloatingBarSeries("Clones 32K");
			int i = 0;
			for (FloatingBar floatingBar : clone) {
				if (i % 8 == 0) {
					floatingBarseries4.add(floatingBar);
				} else if (i % 8 == 1) {
					floatingBarseries5.add(floatingBar);
				} else if (i % 8 == 2) {
					floatingBarseries6.add(floatingBar);
				} else if (i % 8 == 3) {
					floatingBarseries7.add(floatingBar);
				} else if (i % 8 == 4) {
					floatingBarseries8.add(floatingBar);
				} else if (i % 8 == 5) {
					floatingBarseries9.add(floatingBar);
				} else if (i % 8 == 6) {
					floatingBarseries10.add(floatingBar);
				} else {
					floatingBarseries11.add(floatingBar);

				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			floatingBarseriescollection.add(floatingBarseries7);
			floatingBarseriescollection.add(floatingBarseries8);
			floatingBarseriescollection.add(floatingBarseries9);
			floatingBarseriescollection.add(floatingBarseries10);
			floatingBarseriescollection.add(floatingBarseries11);
			titreLignes.add("Clones 32K (1/8)");
			titreLignes.add("Clones 32K (2/8)");
			titreLignes.add("Clones 32K (3/8)");
			titreLignes.add("Clones 32K (4/8)");
			titreLignes.add("Clones 32K (5/8)");
			titreLignes.add("Clones 32K (6/8)");
			titreLignes.add("Clones 32K (7/8)");
			titreLignes.add("Clones 32K (8/8)");
		}
		if (selected.containsKey("Clones Tilepath") && selected.get("Clones Tilepath").booleanValue()) {

			List<FloatingBar> clone = ob.getClonetilepathBandes();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries7 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries9 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries10 = new FloatingBarSeries("Clones Tilepath");
			FloatingBarSeries floatingBarseries11 = new FloatingBarSeries("Clones Tilepath");
			int i = 0;
			for (FloatingBar floatingBar : clone) {
				if (i % 8 == 0) {
					floatingBarseries4.add(floatingBar);
				} else if (i % 8 == 1) {
					floatingBarseries5.add(floatingBar);
				} else if (i % 8 == 2) {
					floatingBarseries6.add(floatingBar);
				} else if (i % 8 == 3) {
					floatingBarseries7.add(floatingBar);
				} else if (i % 8 == 4) {
					floatingBarseries8.add(floatingBar);
				} else if (i % 8 == 5) {
					floatingBarseries9.add(floatingBar);
				} else if (i % 8 == 6) {
					floatingBarseries10.add(floatingBar);
				} else {
					floatingBarseries11.add(floatingBar);

				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			floatingBarseriescollection.add(floatingBarseries7);
			floatingBarseriescollection.add(floatingBarseries8);
			floatingBarseriescollection.add(floatingBarseries9);
			floatingBarseriescollection.add(floatingBarseries10);
			floatingBarseriescollection.add(floatingBarseries11);
			titreLignes.add("Clones Tilepath (1/8)");
			titreLignes.add("Clones Tilepath (2/8)");
			titreLignes.add("Clones Tilepath (3/8)");
			titreLignes.add("Clones Tilepath (4/8)");
			titreLignes.add("Clones Tilepath (5/8)");
			titreLignes.add("Clones Tilepath (6/8)");
			titreLignes.add("Clones Tilepath (7/8)");
			titreLignes.add("Clones Tilepath (8/8)");
		}

		// if (confPanel.cbClone4x44kagilent != null &&
		// confPanel.cbClone4x44kagilent.isSelected()) {
		// List<FloatingBar> clone = ob.getClone4x44kagilentBandes();
		// FloatingBarSeries floatingBarseries4 = new FloatingBarSeries(
		// "Mq 4x44K");
		// for (FloatingBar floatingBar : clone) {
		// floatingBarseries4.add(floatingBar);
		// }
		// floatingBarseriescollection.add(floatingBarseries4);
		//
		// titreLignes.add("Mq 4x44K");
		//
		// }
		if (selected.containsKey("Clones 4K") && selected.get("Clones 4K").booleanValue()) {

			List<FloatingBar> clone = ob.getClone4kBandes();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Clones 4K");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Clones 4K");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Clones 4K");
			int i = 0;
			for (FloatingBar floatingBar : clone) {
				if (i % 3 == 0) {
					floatingBarseries4.add(floatingBar);
				} else if (i % 3 == 1) {
					floatingBarseries5.add(floatingBar);
				} else if (i % 3 == 2) {
					floatingBarseries6.add(floatingBar);
				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			titreLignes.add("Clones 4K (1/3)");
			titreLignes.add("Clones 4K (2/3)");
			titreLignes.add("Clones 4K (3/3)");
		}
		if (selected.containsKey("CNP Lyon") && selected.get("CNP Lyon").booleanValue()) {

			List<FloatingBar> cnp = ob.getCnpLyon();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Cnp de Lyon gain");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Cnp de Lyon triplic.");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Cnp de Lyon perte");
			int i = 0;
			for (FloatingBar floatingBar : cnp) {
				if (floatingBar.getToolTip().contains("Gain")) {
					floatingBarseries4.add(floatingBar);
				} else if (floatingBar.getToolTip().contains("Triplication")) {
					floatingBarseries5.add(floatingBar);
				} else if (floatingBar.getToolTip().contains("Perte")) {
					floatingBarseries6.add(floatingBar);
				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			titreLignes.add("Cnp Lyon gain");
			titreLignes.add("Cnp Lyon triplic.");
			titreLignes.add("Cnp Lyon perte");
		}
		if (selected.containsKey("CNP Nantes, Rouen, Rennes, Lyon") && selected.get("CNP Nantes, Rouen, Rennes, Lyon").booleanValue()) {

			List<FloatingBar> cnp = ob.getCnpOuest();
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("Cnp Ouest gain");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("Cnp Ouest triplic.");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("Cnp Ouest perte");
			int i = 0;
			for (FloatingBar floatingBar : cnp) {
				if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_3)) {
					floatingBarseries4.add(floatingBar);
				} else if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
					floatingBarseries5.add(floatingBar);
				} else if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_1)) {
					floatingBarseries6.add(floatingBar);
				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			titreLignes.add("Cnp Ouest gain");
			titreLignes.add("Cnp Ouest triplic.");
			titreLignes.add("Cnp Ouest perte");
		}
		if (selected.containsKey("CNP Redon") && selected.get("CNP Redon").booleanValue()) {

			floatingBarseriescollection.add(ob.getRedonBandes());
			titreLignes.add("CNP Redon");
		}
		if (selected.containsKey("CNV de la base ISCA") && selected.get("CNV de la base ISCA").booleanValue()) {

			List<FloatingBar> cnp = ob.getISCABandes();

			FloatingBarSeries floatingBarseriesBd1 = new FloatingBarSeries("ISCA Benign del");
			FloatingBarSeries floatingBarseriesBd2 = new FloatingBarSeries("ISCA Benign del");
			FloatingBarSeries floatingBarseriesBd3 = new FloatingBarSeries("ISCA Benign del");
			FloatingBarSeries floatingBarseriesBd4 = new FloatingBarSeries("ISCA Benign del");
			FloatingBarSeries floatingBarseriesBd5 = new FloatingBarSeries("ISCA Benign del");

			FloatingBarSeries floatingBarseriesLBd1 = new FloatingBarSeries("ISCA Likely_Benign del");
			FloatingBarSeries floatingBarseriesLBd2 = new FloatingBarSeries("ISCA Likely_Benign del");
			FloatingBarSeries floatingBarseriesLBd3 = new FloatingBarSeries("ISCA Likely_Benign del");

			FloatingBarSeries floatingBarseriesUd1 = new FloatingBarSeries("ISCA Uncertain del");
			FloatingBarSeries floatingBarseriesUd2 = new FloatingBarSeries("ISCA Uncertain del");
			FloatingBarSeries floatingBarseriesUd3 = new FloatingBarSeries("ISCA Uncertain del");
			FloatingBarSeries floatingBarseriesLPd1 = new FloatingBarSeries("ISCA Likely_Patho del");
			FloatingBarSeries floatingBarseriesLPd2 = new FloatingBarSeries("ISCA Likely_Patho del");
			FloatingBarSeries floatingBarseriesLPd3 = new FloatingBarSeries("ISCA Likely_Patho del");

			FloatingBarSeries floatingBarseriesPd1 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd2 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd3 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd4 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd5 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd6 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd7 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd8 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd9 = new FloatingBarSeries("ISCA Patho del");
			FloatingBarSeries floatingBarseriesPd10 = new FloatingBarSeries("ISCA Patho del");

			FloatingBarSeries floatingBarseriesBi1 = new FloatingBarSeries("ISCA Benign del");
			FloatingBarSeries floatingBarseriesBi2 = new FloatingBarSeries("ISCA Benign dup");
			FloatingBarSeries floatingBarseriesBi3 = new FloatingBarSeries("ISCA Benign dup");
			FloatingBarSeries floatingBarseriesBi4 = new FloatingBarSeries("ISCA Benign dup");
			FloatingBarSeries floatingBarseriesBi5 = new FloatingBarSeries("ISCA Benign dup");

			FloatingBarSeries floatingBarseriesLBi1 = new FloatingBarSeries("ISCA Likely_Benign dup");
			FloatingBarSeries floatingBarseriesLBi2 = new FloatingBarSeries("ISCA Likely_Benign dup");
			FloatingBarSeries floatingBarseriesLBi3 = new FloatingBarSeries("ISCA Likely_Benign dup");

			FloatingBarSeries floatingBarseriesUi1 = new FloatingBarSeries("ISCA Uncertain dup");
			FloatingBarSeries floatingBarseriesUi2 = new FloatingBarSeries("ISCA Uncertain dup");
			FloatingBarSeries floatingBarseriesUi3 = new FloatingBarSeries("ISCA Uncertain dup");
			FloatingBarSeries floatingBarseriesLPi1 = new FloatingBarSeries("ISCA Likely_Patho dup");
			FloatingBarSeries floatingBarseriesLPi2 = new FloatingBarSeries("ISCA Likely_Patho dup");
			FloatingBarSeries floatingBarseriesLPi3 = new FloatingBarSeries("ISCA Likely_Patho dup");

			FloatingBarSeries floatingBarseriesPi1 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi2 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi3 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi4 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi5 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi6 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi7 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi8 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi9 = new FloatingBarSeries("ISCA Patho dup");
			FloatingBarSeries floatingBarseriesPi10 = new FloatingBarSeries("ISCA Patho dup");
			int i = 0;
			int j = 0;
			int k = 0;
			int l = 0;
			int m = 0;
			int n = 0;
			int o = 0;
			int p = 0;
			int q = 0;
			int r = 0;
			FloatingBar floatingBarBdOld = null;
			FloatingBar floatingBarBiOld = null;
			FloatingBar floatingBarLBdOld = null;
			FloatingBar floatingBarLBiOld = null;
			FloatingBar floatingBarUdOld = null;
			FloatingBar floatingBarUiOld = null;
			FloatingBar floatingBarLPdOld = null;
			FloatingBar floatingBarLPiOld = null;
			FloatingBar floatingBarPdOld = null;
			FloatingBar floatingBarPiOld = null;

			for (FloatingBar floatingBar : cnp) {
				if (floatingBar.getToolTip().contains("Benign") && !floatingBar.getToolTip().contains("Likely")) {
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_0)) {
						if (floatingBarBdOld != null && floatingBar.getStart().intValue() <= floatingBarBdOld.getEnd().intValue()) {
							i++;
						}
						if (i % 5 == 0) {
							floatingBarseriesBd1.add(floatingBar);
						} else if (i % 5 == 1) {
							floatingBarseriesBd2.add(floatingBar);
						} else if (i % 5 == 2) {
							floatingBarseriesBd3.add(floatingBar);
						} else if (i % 5 == 3) {
							floatingBarseriesBd4.add(floatingBar);
						} else if (i % 5 == 4) {
							floatingBarseriesBd5.add(floatingBar);
						}
						floatingBarBdOld = floatingBar;
					}
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
						if (floatingBarBiOld != null && floatingBar.getStart().intValue() <= floatingBarBiOld.getEnd().intValue()) {
							j++;
						}
						if (j % 5 == 0) {
							floatingBarseriesBi1.add(floatingBar);
						} else if (j % 5 == 1) {
							floatingBarseriesBi2.add(floatingBar);
						} else if (j % 5 == 2) {
							floatingBarseriesBi3.add(floatingBar);
						} else if (j % 5 == 3) {
							floatingBarseriesBi4.add(floatingBar);
						} else {
							floatingBarseriesBi5.add(floatingBar);
						}
						floatingBarBiOld = floatingBar;
					}
				} else if (floatingBar.getToolTip().contains("Likely_Benign")) {
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_0)) {
						if (floatingBarLBdOld != null && floatingBar.getStart().intValue() <= floatingBarLBdOld.getEnd().intValue()) {
							k++;
						}
						if (k % 3 == 0) {
							floatingBarseriesLBd1.add(floatingBar);
						} else if (k % 3 == 1) {
							floatingBarseriesLBd2.add(floatingBar);
						} else {
							floatingBarseriesLBd3.add(floatingBar);
						}
						floatingBarLBdOld = floatingBar;
					}
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
						if (floatingBarLBiOld != null && floatingBar.getStart().intValue() <= floatingBarLBiOld.getEnd().intValue()) {
							l++;
						}
						if (l % 3 == 0) {
							floatingBarseriesLBi1.add(floatingBar);
						} else if (l % 3 == 1) {
							floatingBarseriesLBi2.add(floatingBar);
						} else {
							floatingBarseriesLBi3.add(floatingBar);
						}
						floatingBarLBiOld = floatingBar;
					}
				} else if (floatingBar.getToolTip().contains("Uncertain")) {
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_0)) {
						if (floatingBarUdOld != null && floatingBar.getStart().intValue() <= floatingBarUdOld.getEnd().intValue()) {
							m++;
						}
						if (m % 3 == 0) {
							floatingBarseriesUd1.add(floatingBar);
						} else if (m % 3 == 1) {
							floatingBarseriesUd2.add(floatingBar);
						} else {
							floatingBarseriesUd3.add(floatingBar);
						}
						floatingBarUdOld = floatingBar;
					}
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
						if (floatingBarUiOld != null && floatingBar.getStart().intValue() <= floatingBarUiOld.getEnd().intValue()) {
							n++;
						}
						if (n % 3 == 0) {
							floatingBarseriesUi1.add(floatingBar);
						} else if (n % 3 == 1) {
							floatingBarseriesUi2.add(floatingBar);
						} else {
							floatingBarseriesUi3.add(floatingBar);
						}
						floatingBarUiOld = floatingBar;
					}
				} else if (floatingBar.getToolTip().contains("Likely_Pathogenic")) {
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_0)) {
						if (floatingBarLPdOld != null && floatingBar.getStart().intValue() <= floatingBarLPdOld.getEnd().intValue()) {
							o++;
						}
						if (o % 3 == 0) {
							floatingBarseriesLPd1.add(floatingBar);
						} else if (o % 3 == 1) {
							floatingBarseriesLPd2.add(floatingBar);
						} else {
							floatingBarseriesLPd3.add(floatingBar);
						}
						floatingBarLPdOld = floatingBar;
					}
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
						if (floatingBarLPiOld != null && floatingBar.getStart().intValue() <= floatingBarLPiOld.getEnd().intValue()) {
							p++;
						}
						if (p % 3 == 0) {
							floatingBarseriesLPi1.add(floatingBar);
						} else if (p % 3 == 1) {
							floatingBarseriesLPi2.add(floatingBar);
						} else {
							floatingBarseriesLPi3.add(floatingBar);
						}
						floatingBarLPiOld = floatingBar;
					}
				} else if (floatingBar.getToolTip().contains("Pathogenic") && !floatingBar.getToolTip().contains("Likely")) {
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_0)) {
						if (floatingBarPdOld != null && floatingBar.getStart().intValue() <= floatingBarPdOld.getEnd().intValue()) {
							q++;
						}
						if (q % 10 == 0) {
							floatingBarseriesPd1.add(floatingBar);
						} else if (q % 10 == 1) {
							floatingBarseriesPd2.add(floatingBar);
						} else if (q % 10 == 2) {
							floatingBarseriesPd3.add(floatingBar);
						} else if (q % 10 == 3) {
							floatingBarseriesPd4.add(floatingBar);
						} else if (q % 10 == 4) {
							floatingBarseriesPd5.add(floatingBar);
						} else if (q % 10 == 5) {
							floatingBarseriesPd6.add(floatingBar);
						} else if (q % 10 == 6) {
							floatingBarseriesPd7.add(floatingBar);
						} else if (q % 10 == 7) {
							floatingBarseriesPd8.add(floatingBar);
						} else if (q % 10 == 8) {
							floatingBarseriesPd9.add(floatingBar);
						} else {
							floatingBarseriesPd10.add(floatingBar);
						}
						floatingBarPdOld = floatingBar;
					}
					if (floatingBar.getColor().equals(GraphCytog.COLOR_CNV_4)) {
						if (floatingBarPiOld != null && floatingBar.getStart().intValue() <= floatingBarPiOld.getEnd().intValue()) {
							r++;
						}
						if (r % 10 == 0) {
							floatingBarseriesPi1.add(floatingBar);
						} else if (r % 10 == 1) {
							floatingBarseriesPi2.add(floatingBar);
						} else if (r % 10 == 2) {
							floatingBarseriesPi3.add(floatingBar);
						} else if (r % 10 == 3) {
							floatingBarseriesPi4.add(floatingBar);
						} else if (r % 10 == 4) {
							floatingBarseriesPi5.add(floatingBar);
						} else if (r % 10 == 5) {
							floatingBarseriesPi6.add(floatingBar);
						} else if (r % 10 == 6) {
							floatingBarseriesPi7.add(floatingBar);
						} else if (r % 10 == 7) {
							floatingBarseriesPi8.add(floatingBar);
						} else if (r % 10 == 8) {
							floatingBarseriesPi9.add(floatingBar);
						} else {
							floatingBarseriesPi10.add(floatingBar);
						}
						floatingBarPiOld = floatingBar;
					}
				}
			}
			floatingBarseriescollection.add(floatingBarseriesBd1);
			floatingBarseriescollection.add(floatingBarseriesBd2);
			floatingBarseriescollection.add(floatingBarseriesBd3);
			floatingBarseriescollection.add(floatingBarseriesBd4);
			floatingBarseriescollection.add(floatingBarseriesBd5);

			floatingBarseriescollection.add(floatingBarseriesBi1);
			floatingBarseriescollection.add(floatingBarseriesBi2);
			floatingBarseriescollection.add(floatingBarseriesBi3);
			floatingBarseriescollection.add(floatingBarseriesBi4);
			floatingBarseriescollection.add(floatingBarseriesBi5);

			floatingBarseriescollection.add(floatingBarseriesLBd1);
			floatingBarseriescollection.add(floatingBarseriesLBd2);
			floatingBarseriescollection.add(floatingBarseriesLBd3);

			floatingBarseriescollection.add(floatingBarseriesLBi1);
			floatingBarseriescollection.add(floatingBarseriesLBi2);
			floatingBarseriescollection.add(floatingBarseriesLBi3);

			floatingBarseriescollection.add(floatingBarseriesUd1);
			floatingBarseriescollection.add(floatingBarseriesUd2);
			floatingBarseriescollection.add(floatingBarseriesUd3);

			floatingBarseriescollection.add(floatingBarseriesUi1);
			floatingBarseriescollection.add(floatingBarseriesUi2);
			floatingBarseriescollection.add(floatingBarseriesUi3);

			floatingBarseriescollection.add(floatingBarseriesLPd1);
			floatingBarseriescollection.add(floatingBarseriesLPd2);
			floatingBarseriescollection.add(floatingBarseriesLPd3);

			floatingBarseriescollection.add(floatingBarseriesLPi1);
			floatingBarseriescollection.add(floatingBarseriesLPi2);
			floatingBarseriescollection.add(floatingBarseriesLPi3);

			floatingBarseriescollection.add(floatingBarseriesPd1);
			floatingBarseriescollection.add(floatingBarseriesPd2);
			floatingBarseriescollection.add(floatingBarseriesPd3);
			floatingBarseriescollection.add(floatingBarseriesPd4);
			floatingBarseriescollection.add(floatingBarseriesPd5);
			floatingBarseriescollection.add(floatingBarseriesPd6);
			floatingBarseriescollection.add(floatingBarseriesPd7);
			floatingBarseriescollection.add(floatingBarseriesPd8);
			floatingBarseriescollection.add(floatingBarseriesPd9);
			floatingBarseriescollection.add(floatingBarseriesPd10);

			floatingBarseriescollection.add(floatingBarseriesPi1);
			floatingBarseriescollection.add(floatingBarseriesPi2);
			floatingBarseriescollection.add(floatingBarseriesPi3);
			floatingBarseriescollection.add(floatingBarseriesPi4);
			floatingBarseriescollection.add(floatingBarseriesPi5);
			floatingBarseriescollection.add(floatingBarseriesPi6);
			floatingBarseriescollection.add(floatingBarseriesPi7);
			floatingBarseriescollection.add(floatingBarseriesPi8);
			floatingBarseriescollection.add(floatingBarseriesPi9);
			floatingBarseriescollection.add(floatingBarseriesPi10);

			titreLignes.add("ISCA Benign del");
			titreLignes.add("ISCA Benign del");
			titreLignes.add("ISCA Benign del");
			titreLignes.add("ISCA Benign del");
			titreLignes.add("ISCA Benign del");
			titreLignes.add("ISCA Benign dup");
			titreLignes.add("ISCA Benign dup");
			titreLignes.add("ISCA Benign dup");
			titreLignes.add("ISCA Benign dup");
			titreLignes.add("ISCA Benign dup");
			titreLignes.add("ISCA Likely_Benign del");
			titreLignes.add("ISCA Likely_Benign del");
			titreLignes.add("ISCA Likely_Benign del");
			titreLignes.add("ISCA Likely_Benign dup");
			titreLignes.add("ISCA Likely_Benign dup");
			titreLignes.add("ISCA Likely_Benign dup");
			titreLignes.add("ISCA Uncertain del");
			titreLignes.add("ISCA Uncertain del");
			titreLignes.add("ISCA Uncertain del");
			titreLignes.add("ISCA Uncertain dup");
			titreLignes.add("ISCA Uncertain dup");
			titreLignes.add("ISCA Uncertain dup");
			titreLignes.add("ISCA Likely_Patho del");
			titreLignes.add("ISCA Likely_Patho del");
			titreLignes.add("ISCA Likely_Patho del");
			titreLignes.add("ISCA Likely_Patho dup");
			titreLignes.add("ISCA Likely_Patho dup");
			titreLignes.add("ISCA Likely_Patho dup");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho del");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
			titreLignes.add("ISCA Patho dup");
		}
		if (selected.containsKey("CNP Montpellier") && selected.get("CNP Montpellier").booleanValue()) {
			floatingBarseriescollection.add(ob.getCnpcBandes());
			titreLignes.add("CNP Montpellier");
		}

		/*
		 * if (confPanel.cbDGV != null && confPanel.cbDGV.isSelected()) {
		 * List<FloatingBar> dgv = ob.getDGVBandes(); FloatingBarSeries
		 * floatingBarseries4 = null; String titre = ""; for (FloatingBar
		 * floatingBar : dgv) { // System.out.print("debut :"
		 * +floatingBar.getTitreLigne()); if
		 * (titre.equals(floatingBar.getTitreLigne())) { //
		 * System.out.print("ADD:"); //
		 * System.out.print(floatingBar.getTitreLigne());
		 * floatingBarseries4.add(floatingBar); } else { if (floatingBarseries4
		 * != null) { floatingBarseriescollection.add(floatingBarseries4); }
		 * floatingBarseries4 = new FloatingBarSeries("DGV : " +
		 * floatingBar.getTitreLigne()); // System.out.print("PAS_ADD:"); //
		 * System.out.print(floatingBar.getTitreLigne()); titre =
		 * floatingBar.getTitreLigne(); titreLignes.add("DGV : " +
		 * floatingBar.getTitreLigne()); } } }
		 */
		if (selected.containsKey("DGV 2013") && selected.get("DGV 2013").booleanValue()) {

			List<FloatingBar> dgv12 = ob.getDGVVariantsBandes();
			FloatingBarSeries floatingBarseries1 = new FloatingBarSeries("DGV 1/20");
			FloatingBarSeries floatingBarseries2 = new FloatingBarSeries("DGV 2/20");
			FloatingBarSeries floatingBarseries3 = new FloatingBarSeries("DGV 3/20");
			FloatingBarSeries floatingBarseries4 = new FloatingBarSeries("DGV 4/20");
			FloatingBarSeries floatingBarseries5 = new FloatingBarSeries("DGV 5/20");
			FloatingBarSeries floatingBarseries6 = new FloatingBarSeries("DGV 6/20");
			FloatingBarSeries floatingBarseries7 = new FloatingBarSeries("DGV 7/20");
			FloatingBarSeries floatingBarseries8 = new FloatingBarSeries("DGV 8/20");
			FloatingBarSeries floatingBarseries9 = new FloatingBarSeries("DGV 9/20");
			FloatingBarSeries floatingBarseries10 = new FloatingBarSeries("DGV 10/20");
			FloatingBarSeries floatingBarseries11 = new FloatingBarSeries("DGV 11/20");
			FloatingBarSeries floatingBarseries12 = new FloatingBarSeries("DGV 12/20");
			FloatingBarSeries floatingBarseries13 = new FloatingBarSeries("DGV 13/20");
			FloatingBarSeries floatingBarseries14 = new FloatingBarSeries("DGV 14/20");
			FloatingBarSeries floatingBarseries15 = new FloatingBarSeries("DGV 15/20");
			FloatingBarSeries floatingBarseries16 = new FloatingBarSeries("DGV 16/20");
			FloatingBarSeries floatingBarseries17 = new FloatingBarSeries("DGV 17/20");
			FloatingBarSeries floatingBarseries18 = new FloatingBarSeries("DGV 18/20");
			FloatingBarSeries floatingBarseries19 = new FloatingBarSeries("DGV 19/20");
			FloatingBarSeries floatingBarseries20 = new FloatingBarSeries("DGV 20/20");
			int i = 0;
			for (FloatingBar floatingBar : dgv12) {
				if (i % 20 == 0) {
					floatingBarseries1.add(floatingBar);
				} else if (i % 20 == 1) {
					floatingBarseries2.add(floatingBar);
				} else if (i % 20 == 2) {
					floatingBarseries3.add(floatingBar);
				} else if (i % 20 == 3) {
					floatingBarseries4.add(floatingBar);
				} else if (i % 20 == 4) {
					floatingBarseries5.add(floatingBar);
				} else if (i % 20 == 5) {
					floatingBarseries6.add(floatingBar);
				} else if (i % 20 == 6) {
					floatingBarseries7.add(floatingBar);
				} else if (i % 20 == 7) {
					floatingBarseries8.add(floatingBar);
				} else if (i % 20 == 8) {
					floatingBarseries9.add(floatingBar);
				} else if (i % 20 == 9) {
					floatingBarseries10.add(floatingBar);
				} else if (i % 20 == 10) {
					floatingBarseries11.add(floatingBar);
				} else if (i % 20 == 11) {
					floatingBarseries12.add(floatingBar);
				} else if (i % 20 == 12) {
					floatingBarseries13.add(floatingBar);
				} else if (i % 20 == 13) {
					floatingBarseries14.add(floatingBar);
				} else if (i % 20 == 14) {
					floatingBarseries15.add(floatingBar);
				} else if (i % 20 == 15) {
					floatingBarseries16.add(floatingBar);
				} else if (i % 20 == 16) {
					floatingBarseries17.add(floatingBar);
				} else if (i % 20 == 17) {
					floatingBarseries18.add(floatingBar);
				} else if (i % 20 == 18) {
					floatingBarseries19.add(floatingBar);
				} else if (i % 20 == 19) {
					floatingBarseries20.add(floatingBar);
				}
				i++;
			}
			floatingBarseriescollection.add(floatingBarseries1);
			floatingBarseriescollection.add(floatingBarseries2);
			floatingBarseriescollection.add(floatingBarseries3);
			floatingBarseriescollection.add(floatingBarseries4);
			floatingBarseriescollection.add(floatingBarseries5);
			floatingBarseriescollection.add(floatingBarseries6);
			floatingBarseriescollection.add(floatingBarseries7);
			floatingBarseriescollection.add(floatingBarseries8);
			floatingBarseriescollection.add(floatingBarseries9);
			floatingBarseriescollection.add(floatingBarseries10);
			floatingBarseriescollection.add(floatingBarseries11);
			floatingBarseriescollection.add(floatingBarseries12);
			floatingBarseriescollection.add(floatingBarseries13);
			floatingBarseriescollection.add(floatingBarseries14);
			floatingBarseriescollection.add(floatingBarseries15);
			floatingBarseriescollection.add(floatingBarseries16);
			floatingBarseriescollection.add(floatingBarseries17);
			floatingBarseriescollection.add(floatingBarseries18);
			floatingBarseriescollection.add(floatingBarseries19);
			floatingBarseriescollection.add(floatingBarseries20);
			titreLignes.add("DGV 1/20");
			titreLignes.add("DGV 2/20");
			titreLignes.add("DGV 3/20");
			titreLignes.add("DGV 4/20");
			titreLignes.add("DGV 5/20");
			titreLignes.add("DGV 6/20");
			titreLignes.add("DGV 7/20");
			titreLignes.add("DGV 8/20");
			titreLignes.add("DGV 9/20");
			titreLignes.add("DGV 10/20");
			titreLignes.add("DGV 11/20");
			titreLignes.add("DGV 12/20");
			titreLignes.add("DGV 13/20");
			titreLignes.add("DGV 14/20");
			titreLignes.add("DGV 15/20");
			titreLignes.add("DGV 16/20");
			titreLignes.add("DGV 17/20");
			titreLignes.add("DGV 18/20");
			titreLignes.add("DGV 19/20");
			titreLignes.add("DGV 20/20");
		}
		if (selected.containsKey("Régions soumises à empreinte génomique") && selected.get("Régions soumises à empreinte génomique").booleanValue()) {

			floatingBarseriescollection.add(ob.getImprintingBandes());
			titreLignes.add("Imprinting région");
		}
		if (selected.containsKey("Variants euchromatiques") && selected.get("Variants euchromatiques").booleanValue()) {

			floatingBarseriescollection.add(ob.getEuchroBandes());
			titreLignes.add("Variant euchro.");
		}
		// if (confPanel.cbMicroRem != null &&
		// confPanel.cbMicroRem.getSelection()) {
		// floatingBarseriescollection.add(ob.getMicroRemBandes());
		// titreLignes.add("MicroRem.OMIM");
		// }
		if (selected.containsKey("Régions chormosomiques fragiles") && selected.get("Régions chormosomiques fragiles").booleanValue()) {

			floatingBarseriescollection.add(ob.getFragile());
			titreLignes.add("Sites fragiles");
		}

		xyFloatingBarDataset = new XYFloatingBarDataset(floatingBarseriescollection);
		xyFloatingBarDataset.setTransposed(true);
		xyFloatingBarDataset.setSeriesWidth(0.59999999999999998D);
		return xyFloatingBarDataset;
	}

	public Map<String, Boolean> getSelected() {
		return selected;
	}

	public void setSelected(Map<String, Boolean> selected) {
		this.selected = selected;
	}

	// public CombinedDomainXYPlot getCombineddomainxyplot() {
	// return combineddomainxyplot;
	// }
	//
	// public void setCombineddomainxyplot(CombinedDomainXYPlot
	// combineddomainxyplot) {
	// this.combineddomainxyplot = combineddomainxyplot;
	// }

	public XYPlot getChromosomePlot() {
		return chromosomePlot;
	}

	public void setChromosomePlot(XYPlot chromosomePlot) {
		this.chromosomePlot = chromosomePlot;
	}

	public void updateData() {
		xyFloatingBarDataset = creationDonneesChromosome();
		// Runnable longJob = new Runnable() {
		// boolean done = false;
		//
		// public void run() {
		// Thread thread = new Thread(new Runnable() {
		// public void run() {
		// xyFloatingBarDataset = creationDonneesChromosome();
		// done = true;
		// }
		// });
		// thread.start();
		// while (!done) {
		// if (!Display.getCurrent().readAndDispatch())
		// Display.getCurrent().sleep();
		// }
		// }
		// };
		// BusyIndicator.showWhile(graph.getcGraph().getDisplay(), longJob);

		SymbolAxis2 symbolaxis = new SymbolAxis2("Type de séq.", titreLignes.toArray(new String[titreLignes.size()]));
		symbolaxis.setGridBandsVisible(true);
		symbolaxis.setAutoRange(false);
		chromosomePlot.setRangeAxis(symbolaxis);
		symbolaxis.setRange(-1, 14);
		symbolaxis.setInverted(true);
		chromosomePlot.setDataset(xyFloatingBarDataset);
		// repaint();

	}

	// public void repaint() {
	// confPanel.repaint();
	// }

	public XYPlot getOverViewPlot() {
		return overviewChromosomePlot;
	}

}